home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / CodeFragments.p < prev    next >
Encoding:
Text File  |  1994-11-11  |  7.9 KB  |  292 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        CodeFragments.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT CodeFragments;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __CODEFRAGMENTS__}
  27. {$SETC __CODEFRAGMENTS__ := 1}
  28.  
  29. {$I+}
  30. {$SETC CodeFragmentsIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __FILES__}
  40. {$I Files.p}
  41. {$ENDC}
  42. {    MixedMode.p                                                    }
  43. {    OSUtils.p                                                    }
  44. {        Memory.p                                                }
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49.  
  50. CONST
  51.     kCFragResourceType            = 'cfrg';
  52.     kCFragResourceID            = 0;
  53.     kCFragLibraryFileType        = 'shlb';
  54.  
  55.     
  56. TYPE
  57.     CFragArchitecture = OSType;
  58.  
  59.  
  60. CONST
  61.     kPowerPCCFragArch            = 'pwpc';
  62.     kMotorola68KCFragArch        = 'm68k';
  63.     kAnyCFragArch                = $3F3F3F3F;
  64.  
  65.     
  66. TYPE
  67.     CFragConnectionID = UInt32;
  68.  
  69.     CFragClosureID = UInt32;
  70.  
  71.     CFragContextID = UInt32;
  72.  
  73.     CFragContainerID = UInt32;
  74.  
  75.     
  76. TYPE
  77.     CFragLoadOptions = UInt32;
  78.  
  79.  
  80. CONST
  81.     kLoadCFrag                    = $01;                            { Try to use existing copy, load if not found.}
  82.     kFindCFrag                    = $02;                            { Try find an existing copy, don't load if not found.}
  83.     kNewCFragCopy                = $05;                            { Load a new copy whether one already exists or not.}
  84.     kInplaceCFrag                = $80;                            { Use data sections directly in the container.}
  85.  
  86.     kUnresolvedCFragSymbolAddress = 0;
  87.  
  88.     
  89. TYPE
  90.     CFragSymbolClass = UInt8;
  91.  
  92.  
  93. CONST
  94.     kCodeCFragSymbol            = 0;
  95.     kDataCFragSymbol            = 1;
  96.     kTVectorCFragSymbol            = 2;
  97.     kTOCCFragSymbol                = 3;
  98.     kGlueCFragSymbol            = 4;
  99.  
  100.     
  101. TYPE
  102.     CFragUsage = UInt8;
  103.  
  104.  
  105. CONST
  106.     kImportLibraryCFrag            = 0;                            { Standard CFM import library.}
  107.     kApplicationCFrag            = 1;                            { Macintosh application.}
  108.     kDropInAdditionCFrag        = 2;                            { Private extension to an application or library.}
  109.  
  110.     kIsCompleteCFrag            = 0;                            { A "base" fragment, not an update.}
  111.     kFirstCFragUpdate            = 1;                            { The first update, others are numbered 2, 3, ...}
  112.  
  113.     
  114. TYPE
  115.     CFragLocatorKind = UInt8;
  116.  
  117.  
  118. CONST
  119.     kMemoryCFragLocator            = 0;                            { Container is already addressable.}
  120.     kDataForkCFragLocator        = 1;                            { Container is in a file's data fork.}
  121.     kResourceCFragLocator        = 2;                            { Container is in a file's resource fork.}
  122.  
  123.     kCFragGoesToEOF                = 0;
  124.  
  125.  
  126. TYPE
  127.     CFragOldMemoryLocator = PACKED RECORD
  128.         address:                LogicalAddress;
  129.         length:                    UInt32;
  130.         inPlace:                BOOLEAN;
  131.         reserved3a:                ARRAY [0..2] OF UInt8;                    { ! Do not use this!}
  132.     END;
  133.     CFragHFSDiskFlatLocator = RECORD
  134.         fileSpec:                FSSpecPtr;
  135.         offset:                    UInt32;
  136.         length:                    UInt32;
  137.     END;
  138. { ! This must have a file specification at the same offset as a data fork locator!}
  139.     CFragHFSSegmentedLocator = PACKED RECORD
  140.         fileSpec:                FSSpecPtr;
  141.         rsrcType:                OSType;
  142.         rsrcID:                    SInt16;
  143.         reserved2a:                UInt16;                                    { ! Do not use this!}
  144.     END;
  145.     CFragHFSLocator = RECORD
  146.         where:                    SInt32;                                    { Really of type CFragLocatorKind.}
  147.         CASE INTEGER OF
  148.         0: (
  149.             onDisk:                        CFragHFSDiskFlatLocator;            { First so debugger shows this form.}
  150.            );
  151.         1: (
  152.             inMem:                        CFragOldMemoryLocator;
  153.            );
  154.         2: (
  155.             inSegs:                        CFragHFSSegmentedLocator;
  156.            );
  157.     END;
  158.     CFragHFSLocatorPtr = ^CFragHFSLocator;
  159.  
  160. { -------------------------------------------------------------------------------------------}
  161. { The parameter block passed to fragment initialization functions.  The locator and name}
  162. { pointers are valid only for the duration of the initialization routine.  I.e. if you want}
  163. { to save the locator or name, save the contents, not the pointers.  Initialization routines}
  164. { take one parameter, a pointer to the parameter block, and return a success/failure result.}
  165. { ! Note that the initialization function returns an OSErr.  Any result other than noErr will}
  166. { ! cause the entire load to be aborted at that point.}
  167.     CFragInitBlock = RECORD
  168.         contextID:                CFragContextID;
  169.         closureID:                CFragClosureID;
  170.         connectionID:            CFragConnectionID;
  171.         fragLocator:            CFragHFSLocator;
  172.         libName:                StringPtr;
  173.         reserved4a:                UInt32;                                    { ! Do not use this!}
  174.         reserved4b:                UInt32;                                    { ! Do not use this!}
  175.         reserved4c:                UInt32;                                    { ! Do not use this!}
  176.         reserved4d:                UInt32;                                    { ! Do not use this!}
  177.     END;
  178.     CFragInitBlockPtr = ^CFragInitBlock;
  179.  
  180.     CFragInitFunction = ProcPtr;  { FUNCTION ((CONST)VAR theInitBlock: CFragInitBlock): OSErr; }
  181.  
  182.     CFragTermRoutine = ProcPtr;  { PROCEDURE ; }
  183.  
  184.     CFragInitFunctionPtr = ^CFragInitFunction;
  185.  
  186.     CFragTermRoutinePtr = ^CFragTermRoutine;
  187.  
  188. { §}
  189. { ===========================================================================================}
  190. { Routines}
  191. { ========}
  192.  
  193. FUNCTION GetSharedLibrary(libName: ConstStr63Param; archType: OSType; loadFlags: CFragLoadOptions; VAR connID: CFragConnectionID; VAR mainAddr: Ptr; VAR errMessage: Str255): OSErr;
  194.     {$IFC NOT GENERATINGCFM}
  195.     INLINE $3F3C, $0001, $AA5A;
  196.     {$ENDC}
  197. FUNCTION GetDiskFragment({CONST}VAR fileSpec: FSSpec; offset: UInt32; length: UInt32; fragName: ConstStr63Param; loadFlags: CFragLoadOptions; VAR connID: CFragConnectionID; VAR mainAddr: Ptr; VAR errMessage: Str255): OSErr;
  198.     {$IFC NOT GENERATINGCFM}
  199.     INLINE $3F3C, $0002, $AA5A;
  200.     {$ENDC}
  201. FUNCTION GetMemFragment(memAddr: UNIV Ptr; length: UInt32; fragName: ConstStr63Param; loadFlags: CFragLoadOptions; VAR connID: CFragConnectionID; VAR mainAddr: Ptr; VAR errMessage: Str255): OSErr;
  202.     {$IFC NOT GENERATINGCFM}
  203.     INLINE $3F3C, $0003, $AA5A;
  204.     {$ENDC}
  205. FUNCTION CloseConnection(VAR connID: CFragConnectionID): OSErr;
  206.     {$IFC NOT GENERATINGCFM}
  207.     INLINE $3F3C, $0004, $AA5A;
  208.     {$ENDC}
  209. FUNCTION FindSymbol(connID: CFragConnectionID; symName: ConstStr255Param; VAR symAddr: Ptr; VAR symClass: CFragSymbolClass): OSErr;
  210.     {$IFC NOT GENERATINGCFM}
  211.     INLINE $3F3C, $0005, $AA5A;
  212.     {$ENDC}
  213. FUNCTION CountSymbols(connID: CFragConnectionID; VAR symCount: LONGINT): OSErr;
  214.     {$IFC NOT GENERATINGCFM}
  215.     INLINE $3F3C, $0006, $AA5A;
  216.     {$ENDC}
  217. FUNCTION GetIndSymbol(connID: CFragConnectionID; symIndex: LONGINT; VAR symName: Str255; VAR symAddr: Ptr; VAR symClass: CFragSymbolClass): OSErr;
  218.     {$IFC NOT GENERATINGCFM}
  219.     INLINE $3F3C, $0007, $AA5A;
  220.     {$ENDC}
  221. {$IFC OLDROUTINENAMES }
  222.     
  223. TYPE
  224.     ConnectionID = CFragConnectionID;
  225.  
  226.     LoadFlags = CFragLoadOptions;
  227.  
  228.     SymClass = CFragSymbolClass;
  229.  
  230.     MemFragment = CFragOldMemoryLocator;
  231.  
  232.     DiskFragment = CFragHFSDiskFlatLocator;
  233.  
  234.     SegmentedFragment = CFragHFSSegmentedLocator;
  235.  
  236.     FragmentLocator = CFragHFSLocator;
  237.  
  238.     FragmentLocatorPtr = CFragHFSLocatorPtr;
  239.  
  240.     InitBlock = CFragInitBlock;
  241.  
  242.     InitBlockPtr = CFragInitBlockPtr;
  243.  
  244.     ConnectionInitializationRoutine = CFragInitFunction;
  245.  
  246.     ConnectionTerminationRoutine = CFragTermRoutine;
  247.  
  248.  
  249. CONST
  250.     kPowerPCArch                = kPowerPCCFragArch;
  251.     kMotorola68KArch            = kMotorola68KCFragArch;
  252.     kAnyArchType                = kAnyCFragArch;
  253.     kNoLibName                    = 0;
  254.     kNoConnectionID                = 0;
  255.     kLoadLib                    = kLoadCFrag;
  256.     kFindLib                    = kFindCFrag;
  257.     kLoadNewCopy                = kNewCFragCopy;
  258.     kUseInPlace                    = kInplaceCFrag;
  259.     kCodeSym                    = kCodeCFragSymbol;
  260.     kDataSym                    = kDataCFragSymbol;
  261.     kTVectSym                    = kTVectorCFragSymbol;
  262.     kTOCSym                        = kTOCCFragSymbol;
  263.     kGlueSym                    = kGlueCFragSymbol;
  264.     kInMem                        = kMemoryCFragLocator;
  265.     kOnDiskFlat                    = kDataForkCFragLocator;
  266.     kOnDiskSegmented            = kResourceCFragLocator;
  267.     kIsLib                        = kImportLibraryCFrag;
  268.     kIsApp                        = kApplicationCFrag;
  269.     kIsDropIn                    = kDropInAdditionCFrag;
  270.     kFullLib                    = kIsCompleteCFrag;
  271.     kUpdateLib                    = kFirstCFragUpdate;
  272.     kCFMRsrcType                = kCFragResourceType;
  273.     kCFMRsrcID                    = kCFragResourceID;
  274.     kSHLBFileType                = kCFragLibraryFileType;
  275.     kUnresolvedSymbolAddress    = kUnresolvedCFragSymbolAddress;
  276.  
  277.     kPowerPC                    = kPowerPCCFragArch;
  278.     kMotorola68K                = kMotorola68KCFragArch;
  279.  
  280. {$ENDC}
  281.  
  282. {$ALIGN RESET}
  283. {$POP}
  284.  
  285. {$SETC UsingIncludes := CodeFragmentsIncludes}
  286.  
  287. {$ENDC} {__CODEFRAGMENTS__}
  288.  
  289. {$IFC NOT UsingIncludes}
  290.  END.
  291. {$ENDC}
  292.